import { createRouter, createWebHistory } from 'vue-router';
import Layout from '@/layout/MainLayout.vue';

const routes = [
  {
    path: '/',
    component: Layout,
    redirect: '/main-system',
    children: [
      {
        path: 'dashboard',
        name: 'Dashboard',
        component: () => import('@/views/UserDashboard.vue'),
        meta: { title: '仪表盘' }
      },
      {
        path: 'home',
        name: 'Home',
        component: () => import('@/views/HomeView.vue'),
        meta: { title: '首页' }
      },
      {
        path: 'main-system',
        name: 'MainSystem',
        component: () => import('@/views/MainSystem.vue'),
        meta: { title: '主系统' }
      },
      {
        path: 'resource-management',
        name: 'ResourceManagement',
        component: () => import('@/views/ResourceManagement.vue'),
        meta: { title: '资源管理' }
      },
      {
        path: 'role-management',
        name: 'RoleManagement',
        component: () => import('@/views/RoleManagement.vue'),
        meta: { title: '角色管理' }
      },
      {
        path: 'sub-system-manager',
        name: 'SubSystemManager',
        component: () => import('@/views/SubSystemManager.vue'),
        meta: { title: '子系统管理' }
      },
      {
        path: 'user-center',
        name: 'UserCenter',
        component: () => import('@/views/UserCenter.vue'),
        meta: { title: '用户中心' }
      },
      {
        path: 'user-management',
        name: 'UserManagement',
        component: () => import('@/views/UserManagement.vue'),
        meta: { title: '用户管理' }
      },
      {
        path: 'login',
        name: 'Login',
        component: () => import('@/views/MainLogin.vue'),
        meta: { title: '登录' }
      }
    ]
  }
];

const router = createRouter({
  history: createWebHistory(process.env.VUE_APP_BASE_URL), // 使用 process.env.VUE_APP_BASE_URL
  routes
});

export default router;